<cfcomponent output="false">

	<cffunction name="read" output="false" access="public" returntype="slr.components.cfgenerated.Instituicao_Detail.EquipamentoBean">
		<cfargument name="id" required="true">
		<cfset var qRead="">
		<cfset var obj="">

		<cfquery name="qRead" datasource="BRUST">
			select 	equipamentoId, institucaoId, equipamentoTipoId, rotulo, tipo, fabricante, 
					modelo, serieTubo, tensaoMaxima, correnteMaxima, tamanhoFocal, 
					gerador, dataCadastro, tecnicoCadastro, dataAlteracao, tecnicoAlteracao
					
			from dbo.Equipamento
			where equipamentoId = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#arguments.id#" />
		</cfquery>

		<cfscript>
			obj = createObject("component", "slr.components.cfgenerated.Instituicao_Detail.EquipamentoBean").init();
			obj.setequipamentoId(qRead.equipamentoId);
			obj.setinstitucaoId(qRead.institucaoId);
			obj.setequipamentoTipoId(qRead.equipamentoTipoId);
			obj.setrotulo(qRead.rotulo);
			obj.settipo(qRead.tipo);
			obj.setfabricante(qRead.fabricante);
			obj.setmodelo(qRead.modelo);
			obj.setserieTubo(qRead.serieTubo);
			obj.settensaoMaxima(qRead.tensaoMaxima);
			obj.setcorrenteMaxima(qRead.correnteMaxima);
			obj.settamanhoFocal(qRead.tamanhoFocal);
			obj.setgerador(qRead.gerador);
			obj.setdataCadastro(qRead.dataCadastro);
			obj.settecnicoCadastro(qRead.tecnicoCadastro);
			obj.setdataAlteracao(qRead.dataAlteracao);
			obj.settecnicoAlteracao(qRead.tecnicoAlteracao);
			return obj;
		</cfscript>
	</cffunction>

	<cffunction name="create" output="false" access="public" returntype="void">
		<cfargument name="bean" required="true" type="slr.components.cfgenerated.Instituicao_Detail.EquipamentoBean">
		<cfset var qCreate="">

		<cfset var qGetId="">

		<cfset var local1=arguments.bean.getinstitucaoId()>
		<cfset var local2=arguments.bean.getequipamentoTipoId()>
		<cfset var local3=arguments.bean.getrotulo()>
		<cfset var local4=arguments.bean.gettipo()>
		<cfset var local5=arguments.bean.getfabricante()>
		<cfset var local6=arguments.bean.getmodelo()>
		<cfset var local7=arguments.bean.getserieTubo()>
		<cfset var local8=arguments.bean.gettensaoMaxima()>
		<cfset var local9=arguments.bean.getcorrenteMaxima()>
		<cfset var local10=arguments.bean.gettamanhoFocal()>
		<cfset var local11=arguments.bean.getgerador()>
		<cfset var local12=arguments.bean.getdataCadastro()>
		<cfset var local13=arguments.bean.gettecnicoCadastro()>
		<cfset var local14=arguments.bean.getdataAlteracao()>
		<cfset var local15=arguments.bean.gettecnicoAlteracao()>

		<cfquery name="qCreate" datasource="BRUST">
			insert into dbo.Equipamento(institucaoId, equipamentoTipoId, rotulo, tipo, fabricante, modelo, serieTubo, tensaoMaxima, correnteMaxima, tamanhoFocal, gerador, dataCadastro, tecnicoCadastro, dataAlteracao, tecnicoAlteracao)
			values (
				<cfqueryparam value="#local1#" cfsqltype="CF_SQL_INTEGER" null="#iif((local1 eq ""), de("yes"), de("no"))#" />,
				<cfqueryparam value="#local2#" cfsqltype="CF_SQL_INTEGER" null="#iif((local2 eq ""), de("yes"), de("no"))#" />,
				<cfqueryparam value="#local3#" cfsqltype="CF_SQL_VARCHAR" />,
				<cfqueryparam value="#local4#" cfsqltype="CF_SQL_VARCHAR" />,
				<cfqueryparam value="#local5#" cfsqltype="CF_SQL_VARCHAR" />,
				<cfqueryparam value="#local6#" cfsqltype="CF_SQL_VARCHAR" />,
				<cfqueryparam value="#local7#" cfsqltype="CF_SQL_VARCHAR" />,
				<cfqueryparam value="#local8#" cfsqltype="CF_SQL_INTEGER" null="#iif((local8 eq ""), de("yes"), de("no"))#" />,
				<cfqueryparam value="#local9#" cfsqltype="CF_SQL_INTEGER" null="#iif((local9 eq ""), de("yes"), de("no"))#" />,
				<cfqueryparam value="#local10#" cfsqltype="CF_SQL_VARCHAR" />,
				<cfqueryparam value="#local11#" cfsqltype="CF_SQL_VARCHAR" />,
				<cfqueryparam value="#local12#" cfsqltype="CF_SQL_TIMESTAMP" null="#iif((local12 eq ""), de("yes"), de("no"))#" />,
				<cfqueryparam value="#local13#" cfsqltype="CF_SQL_VARCHAR" />,
				<cfqueryparam value="#local14#" cfsqltype="CF_SQL_TIMESTAMP" null="#iif((local14 eq ""), de("yes"), de("no"))#" />,
				<cfqueryparam value="#local15#" cfsqltype="CF_SQL_VARCHAR" />
			)
		</cfquery>

		<!--- If your server has a better way to get the ID that is more reliable, use that instead --->
		<cfquery name="qGetID" datasource="BRUST">
			select equipamentoId
			from dbo.Equipamento
			where institucaoId = <cfqueryparam value="#local1#" cfsqltype="CF_SQL_INTEGER" null="#iif((local1 eq ""), de("yes"), de("no"))#" />
			  and equipamentoTipoId = <cfqueryparam value="#local2#" cfsqltype="CF_SQL_INTEGER" null="#iif((local2 eq ""), de("yes"), de("no"))#" />
			  and rotulo = <cfqueryparam value="#local3#" cfsqltype="CF_SQL_VARCHAR" />
			  and tipo = <cfqueryparam value="#local4#" cfsqltype="CF_SQL_VARCHAR" />
			  and fabricante = <cfqueryparam value="#local5#" cfsqltype="CF_SQL_VARCHAR" />
			  and modelo = <cfqueryparam value="#local6#" cfsqltype="CF_SQL_VARCHAR" />
			  and serieTubo = <cfqueryparam value="#local7#" cfsqltype="CF_SQL_VARCHAR" />
			  and tensaoMaxima = <cfqueryparam value="#local8#" cfsqltype="CF_SQL_INTEGER" null="#iif((local8 eq ""), de("yes"), de("no"))#" />
			  and correnteMaxima = <cfqueryparam value="#local9#" cfsqltype="CF_SQL_INTEGER" null="#iif((local9 eq ""), de("yes"), de("no"))#" />
			  and tamanhoFocal = <cfqueryparam value="#local10#" cfsqltype="CF_SQL_VARCHAR" />
			  and gerador = <cfqueryparam value="#local11#" cfsqltype="CF_SQL_VARCHAR" />
			  and dataCadastro = <cfqueryparam value="#local12#" cfsqltype="CF_SQL_TIMESTAMP" null="#iif((local12 eq ""), de("yes"), de("no"))#" />
			  and tecnicoCadastro = <cfqueryparam value="#local13#" cfsqltype="CF_SQL_VARCHAR" />
			  and dataAlteracao = <cfqueryparam value="#local14#" cfsqltype="CF_SQL_TIMESTAMP" null="#iif((local14 eq ""), de("yes"), de("no"))#" />
			  and tecnicoAlteracao = <cfqueryparam value="#local15#" cfsqltype="CF_SQL_VARCHAR" />
			order by equipamentoId desc
		</cfquery>
		<cfscript>
			arguments.bean.setequipamentoId(qGetID.equipamentoId);
		</cfscript>
	</cffunction>



	<cffunction name="update" output="false" access="public" returntype="void">
		<cfargument name="bean" required="true" type="slr.components.cfgenerated.Instituicao_Detail.EquipamentoBean">
		<cfset var qUpdate="">

		<cfquery name="qUpdate" datasource="" result="status">
			update dbo.Equipamento
			set institucaoId = <cfqueryparam value="#arguments.bean.getinstitucaoId()#" cfsqltype="CF_SQL_INTEGER" null="#iif((arguments.bean.getinstitucaoId() eq ""), de("yes"), de("no"))#" />,
				equipamentoTipoId = <cfqueryparam value="#arguments.bean.getequipamentoTipoId()#" cfsqltype="CF_SQL_INTEGER" null="#iif((arguments.bean.getequipamentoTipoId() eq ""), de("yes"), de("no"))#" />,
				rotulo = <cfqueryparam value="#arguments.bean.getrotulo()#" cfsqltype="CF_SQL_VARCHAR" />,
				tipo = <cfqueryparam value="#arguments.bean.gettipo()#" cfsqltype="CF_SQL_VARCHAR" />,
				fabricante = <cfqueryparam value="#arguments.bean.getfabricante()#" cfsqltype="CF_SQL_VARCHAR" />,
				modelo = <cfqueryparam value="#arguments.bean.getmodelo()#" cfsqltype="CF_SQL_VARCHAR" />,
				serieTubo = <cfqueryparam value="#arguments.bean.getserieTubo()#" cfsqltype="CF_SQL_VARCHAR" />,
				tensaoMaxima = <cfqueryparam value="#arguments.bean.gettensaoMaxima()#" cfsqltype="CF_SQL_INTEGER" null="#iif((arguments.bean.gettensaoMaxima() eq ""), de("yes"), de("no"))#" />,
				correnteMaxima = <cfqueryparam value="#arguments.bean.getcorrenteMaxima()#" cfsqltype="CF_SQL_INTEGER" null="#iif((arguments.bean.getcorrenteMaxima() eq ""), de("yes"), de("no"))#" />,
				tamanhoFocal = <cfqueryparam value="#arguments.bean.gettamanhoFocal()#" cfsqltype="CF_SQL_VARCHAR" />,
				gerador = <cfqueryparam value="#arguments.bean.getgerador()#" cfsqltype="CF_SQL_VARCHAR" />,
				dataCadastro = <cfqueryparam value="#arguments.bean.getdataCadastro()#" cfsqltype="CF_SQL_TIMESTAMP" null="#iif((arguments.bean.getdataCadastro() eq ""), de("yes"), de("no"))#" />,
				tecnicoCadastro = <cfqueryparam value="#arguments.bean.gettecnicoCadastro()#" cfsqltype="CF_SQL_VARCHAR" />,
				dataAlteracao = <cfqueryparam value="#arguments.bean.getdataAlteracao()#" cfsqltype="CF_SQL_TIMESTAMP" null="#iif((arguments.bean.getdataAlteracao() eq ""), de("yes"), de("no"))#" />,
				tecnicoAlteracao = <cfqueryparam value="#arguments.bean.gettecnicoAlteracao()#" cfsqltype="CF_SQL_VARCHAR" />
			where equipamentoId = <cfqueryparam value="#arguments.bean.getequipamentoId()#" cfsqltype="CF_SQL_INTEGER">
		</cfquery>
	</cffunction>



	<cffunction name="delete" output="false" access="public" returntype="void">
		<cfargument name="bean" required="true" type="slr.components.cfgenerated.Instituicao_Detail.EquipamentoBean">
		<cfset var qDelete="">

		<cfquery name="qDelete" datasource="BRUST" result="status">
			delete
			from dbo.Equipamento
			where equipamentoId = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#arguments.bean.getequipamentoId()#" />
		</cfquery>

	</cffunction>


</cfcomponent>